package com.oocl.ha.entity;

import java.io.Serializable;
import java.util.Set;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.OneToMany;
import javax.persistence.Table;

import com.fasterxml.jackson.annotation.JsonBackReference;
import com.fasterxml.jackson.annotation.JsonManagedReference;

@Entity
@Table(name = "tmerchant")
public class Merchant implements Serializable {

	@Id
	@Column(name = "mid")
	@GeneratedValue(strategy = GenerationType.SEQUENCE)
	private Integer mid;

	@Column(name = "account")
	private String account;

	@Column(name = "password")
	private String password;

	@Column(name = "icon")
	private String icon;

	@Column(name = "shopname")
	private String shopName;

	@Column(name = "address")
	private String address;

	@Column(name = "star")
	private Double star;

	@Column(name = "ordernumber")
	private Integer orderNumber;

	@Column(name = "statue")
	private Integer statue;


	@JsonBackReference
	@OneToMany(targetEntity = Dish.class, mappedBy = "merchant", cascade = CascadeType.ALL, fetch = FetchType.LAZY)
	private Set<Dish> dishs;
	@JsonBackReference
	@OneToMany(targetEntity = Order.class, mappedBy = "merchant", cascade = CascadeType.ALL, fetch = FetchType.LAZY)
	private Set<Order> orders;

	public Merchant() {
		super();
	}

	public Merchant(String account, String password, String icon, String shopName, String address, Double star,
			Integer orderNumber, Integer statue, Set<Dish> dishs, Set<Order> orders) {
		super();
		this.account = account;
		this.password = password;
		this.icon = icon;
		this.shopName = shopName;
		this.address = address;
		this.star = star;
		this.orderNumber = orderNumber;
		this.statue = statue;
		this.dishs = dishs;
		this.orders = orders;
	}

	public Merchant(Integer mid, String account, String password, String icon, String shopName, String address,
			Double star, Integer orderNumber, Integer statue, Set<Dish> dishs, Set<Order> orders) {
		super();
		this.mid = mid;
		this.account = account;
		this.password = password;
		this.icon = icon;
		this.shopName = shopName;
		this.address = address;
		this.star = star;
		this.orderNumber = orderNumber;
		this.statue = statue;
		this.dishs = dishs;
		this.orders = orders;
	}

	public Integer getMid() {
		return mid;
	}

	public void setMid(Integer mid) {
		this.mid = mid;
	}

	public String getAccount() {
		return account;
	}

	public void setAccount(String account) {
		this.account = account;
	}

	public String getPassword() {
		return password;
	}

	public void setPassword(String password) {
		this.password = password;
	}

	public String getIcon() {
		return icon;
	}

	public void setIcon(String icon) {
		this.icon = icon;
	}

	public String getShopName() {
		return shopName;
	}

	public void setShopName(String shopName) {
		this.shopName = shopName;
	}

	public String getAddress() {
		return address;
	}

	public void setAddress(String address) {
		this.address = address;
	}

	public Double getStar() {
		return star;
	}

	public void setStar(Double star) {
		this.star = star;
	}

	public Integer getOrderNumber() {
		return orderNumber;
	}

	public void setOrderNumber(Integer orderNumber) {
		this.orderNumber = orderNumber;
	}

	public Integer getStatue() {
		return statue;
	}

	public void setStatue(Integer statue) {
		this.statue = statue;
	}

	public Set<Dish> getDishs() {
		return dishs;
	}

	public void setDishs(Set<Dish> dishs) {
		this.dishs = dishs;
	}

	public Set<Order> getOrders() {
		return orders;
	}

	public void setOrders(Set<Order> orders) {
		this.orders = orders;
	}

}
